#include "PO_MoM.h"
#include <cmath>
using namespace blitz;
void SavingEdgeLength()
{
	for (int i=0; i<iEdge; i++)
	{
		int node1 = Edge(i,0);
		int node2 = Edge(i,1);
		Edge_length(i) = sqrt(dot((vNode(node1)-vNode(node2)),(vNode(node1)-vNode(node2))));
	}
}

void SavingPatchCenterAndNormal()
{
	for (int i=0; i<iPatch; i++)
	{
		int node1 = Patch(i,0);
		int node2 = Patch(i,1);
		int node3 = Patch(i,2);
		Position3D R1,R2,R3;
		R1 = vNode(node1);
		R2 = vNode(node2);
		R3 = vNode(node3);
		vPatchCtr(i) = (R1+R2+R3)/3;
		Position3D R12,R23;
		R12 = R2-R1;
		R23 = R3-R2;
		Position3D tmp = cross(R12,R23);
		vPatchNorm(i) = tmp/sqrt(dot(tmp,tmp));
	}
}
void SavingT()
{
	for (int i=0; i<iEdge; i++)
	{
		Position3D tmp1, tmp2, tmp3;
		tmp1 = (vNode(Edge(i,1))-vNode(Edge(i,0)))/Edge_length(i);
		tmp2 = vPatchNorm(Edge(i,2));
		tmp3 = vPatchNorm(Edge(i,3));
		Position3D T_plus, T_minus;
		T_plus = cross(tmp1,tmp2);
		T_minus = cross(tmp1,tmp3);
		T(i) = T_plus + T_minus;
	}
}
